<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	int role = (int)request.getSession().getAttribute("role");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>卡客途安轮卫管家</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="<%=path %>/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/css/google.css" rel="stylesheet">
<link href="<%=path %>/css/style.css" rel="stylesheet" type="text/css">
<link href="<%=path %>/css/font-awesome.css" rel="stylesheet">
<link rel="apple-touch-icon" sizes="76x76" href="<%=path %>/img/logo.png">
<link rel="icon" type="image/png" sizes="96x96" href="<%=path %>/img/logo.png">
<style type="text/css">
html,body{
min-height:100%;
}
</style>
</head>
<body style="margin:0 auto;height: 100%" id="body">
<!-- header -->
<jsp:include page="header.jsp"></jsp:include>
<!-- main -->
<div class="main">
  <div class="main-inner">
    <div class="container">
      <div class="row">
        <div class="span12">
          <!-- /widget -->
          <div class="widget widget-table action-table">
            <div class="widget-header"> 
              <i class="icon-th-list"></i>
              <h3>分公司</h3>
              <!-- <button type="submit" class="btn btn-primary" onclick="" style="float: right;margin-top:6px;margin-right:5px;">添加</button> -->
            </div>
            <!-- /widget-header -->
            <div class="widget-content">
            	<div class="tabbable">
					<!-- <ul class="nav nav-tabs">
					  <li>
					    <a href="#formcontrols" data-toggle="tab">Form Controls</a>
					  </li>
					  <li  class="active"><a href="#jscontrols" data-toggle="tab">JS Controls</a></li>
					</ul>
					<br> -->
					<div class="tab-content">
						<form id="form01" class="form-horizontal" method="POST">
								<br />
								<div class="control-group">											
									<label class="control-label" for="name">账号<span style="color: red">*</span></label>
									<div class="controls">
										<input type="text" class="span6" id="name" name="name" value="${user.name }">
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="password">密码<span style="color: red">*</span></label>
									<div class="controls">
										<input type="text" class="span6" id="password" name="password" value='${user.password }'>
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="nickName">姓名<span style="color: red">*</span></label>
									<div class="controls">
										<input type="text" class="span6" id="nickName" name="nickName" value="${user.nickName }">
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="idcard">身份证</label>
									<div class="controls">
										<input type="text" class="span6" id="idcard" name="idcard" value="${user.idcard }">
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="phone">联系电话</label>
									<div class="controls">
										<input type="text" class="span6" id="phone" name="phone" value="${user.phone }">
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="fleetId">车队<span style="color: red">*</span></label>
									<div class="controls">
										<select name="fleetId" id="fleetId" class="span6">
											<option value="">请选择</option>
											<c:forEach items="${fleets }" var="f">
												<option value="${f.id }"  <c:if test="${f.id==user.fleetId }">selected</c:if> >${f.name }</option>
											</c:forEach>
										</select>
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group">											
									<label class="control-label" for="positionId">职位</label>
									<div class="controls">
										<select name="positionId" id="positionId" class="span6">
											<option value="">请选择</option>
											<c:forEach items="${positions }" var="p">
												<option value="${p.id }"  <c:if test="${p.id==user.positionId }">selected</c:if> >${p.name }</option>
											</c:forEach>
										</select>
									</div> <!-- /controls -->				
								</div> <!-- /control-group -->
								<div class="control-group" id="msg" style="text-align: center;color: red">${msg }</div> 
								<div class="form-actions" style="text-align: center;">
									<input type="hidden" id="id" name="id" value="${user.id }">
									<input type="hidden" id="role" name="role" value="2">
									<button type="button"  id="sub" class="btn btn-primary">提交</button> 
									<button type="button" class="btn" onclick="location.href='<%=path%>/user/query.html'">取消</button>
								</div> <!-- /form-actions -->
						</form>
					</div>
				</div>
			 </div> <!-- /widget-content --> 
          </div>
          <!-- /widget --> 
        </div>
        <!-- /span6 --> 
      </div>
      <!-- /row --> 
    </div>
    <!-- /container --> 
  </div>
  <!-- /main-inner --> 
  <br>
  <br>
  <br>
</div>
<!-- /main -->
<jsp:include page="footer.jsp"></jsp:include>
<!-- Le javascript
================================================== --> 
<!-- Placed at the end of the document so the pages load faster --> 
<script src="<%=path %>/js/jquery-1.7.2.min.js"></script> 
<script src="<%=path %>/js/excanvas.min.js"></script>
<script src="<%=path %>/js/bootstrap.js"></script>
<script src="<%=path %>/js/base.js"></script>
<script type="text/javascript">
var minheight = $(window).height();
$("#body").css({
  'min-height':minheight +'px'
})
$("#sub").click(function(){
	if($("#name").val()==""){
		alert("请输入账号");
		return;
	}
	if($("#password").val()==""){
		alert("请输密码");
		return;
	}
	if($("#nickName").val()==""){
		alert("请输入姓名");
		return;
	}
	if($("#fleetId").val()==""){
		alert("请选择所属车队");
		return;
	}
	$.ajax({
		    url:'<%=path %>/user/add.html',
		    type:'POST', //GET
		    async:true,    //或false,是否异步
		    data: $("#form01").serializeArray(),
		    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
		    success:function(data){
		        if(data.resCode=="0"){
		        	if($("#id").val() != ""){
		        		alert("修改成功！");
		        	}else{
		        		alert("添加成功！");
		        	}
		        	window.location.href="<%=path %>/user/query.html";
		        }else{
		        	 $("#msg").html(data.resMsg);
		        }
		    },
		    error:function(xhr){},
		});
})
</script>
</body>
</html>